<?php

/**
 * Articulo form base class.
 *
 * @method Articulo getObject() Returns the current form's model object
 *
 * @package    catalogo
 * @subpackage form
 * @author     Ignacio Di Rocco
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseArticuloForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'categoria_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'), 'add_empty' => false)),
      'usuario_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Usuario'), 'add_empty' => false)),
      'tipo_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoArticulo'), 'add_empty' => false)),
      'titulo'        => new sfWidgetFormInputText(),
      'ubicacion_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Ubicacion'), 'add_empty' => false)),
      'descripcion'   => new sfWidgetFormTextarea(),
      'forma_pago_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('FormaPago'), 'add_empty' => false)),
      'precio'        => new sfWidgetFormInputText(),
      'moneda'        => new sfWidgetFormInputText(),
      'token'         => new sfWidgetFormInputText(),
      'publicado'     => new sfWidgetFormInputCheckbox(),
      'destacado'     => new sfWidgetFormInputCheckbox(),
      'visitas'       => new sfWidgetFormInputText(),
      'orden'         => new sfWidgetFormInputText(),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'categoria_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'))),
      'usuario_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Usuario'))),
      'tipo_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TipoArticulo'))),
      'titulo'        => new sfValidatorString(array('max_length' => 255)),
      'ubicacion_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Ubicacion'))),
      'descripcion'   => new sfValidatorString(array('max_length' => 4000)),
      'forma_pago_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('FormaPago'))),
      'precio'        => new sfValidatorString(array('max_length' => 255)),
      'moneda'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'token'         => new sfValidatorString(array('max_length' => 255)),
      'publicado'     => new sfValidatorBoolean(array('required' => false)),
      'destacado'     => new sfValidatorBoolean(array('required' => false)),
      'visitas'       => new sfValidatorInteger(array('required' => false)),
      'orden'         => new sfValidatorInteger(array('required' => false)),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Articulo', 'column' => array('token')))
    );

    $this->widgetSchema->setNameFormat('articulo[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Articulo';
  }

}
